/*
 * Copyright (C) 2022 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

#include "categoryitem.h"
#include <QMetaEnum>

class CategoryItemPrivate {
public:
    int category;
    QString name;
    QString icon;
    QString normalIcon;
    QString clickIcon;
    int pageCount;
};

CategoryItem::CategoryItem(QObject *parent)
    : QObject(parent)
    , p(new CategoryItemPrivate)
{

}

CategoryItem::~CategoryItem()
{
    delete p;
}

int CategoryItem::category() const
{
    return p->category;
}

void CategoryItem::setCategory(const int &category)
{
    if (p->category != category) {
        p->category = category;
        Q_EMIT categoryChanged();
    }
}

QString CategoryItem::name() const
{
    return p->name;
}

void CategoryItem::setName(const QString &name)
{
    if (p->name != name) {
        p->name = name;
        Q_EMIT nameChanged();
    }
}

QString CategoryItem::normalIcon() const
{
    return p->normalIcon;
}

void CategoryItem::setNormalIcon(const QString &icon)
{
    if (p->normalIcon != icon) {
        p->normalIcon = icon;
        Q_EMIT normalIconChanged();
    }
}

QString CategoryItem::clickIcon() const
{
    return p->clickIcon;
}

void CategoryItem::setClickIcon(const QString &icon)
{
    if (p->clickIcon != icon) {
        p->clickIcon = icon;
        Q_EMIT clickIconChanged();
    }
}

int CategoryItem::pageCount() const
{
    return p->pageCount;
}

void CategoryItem::setPageCount(const int &pageCount)
{
    if (p->pageCount != pageCount) {
        p->pageCount = pageCount;
        Q_EMIT pageCountChanged();
    }
}

QString CategoryItem::categoryToString(Category category)
{
    QMetaEnum categoryEnum = QMetaEnum::fromType<CategoryItem::Category>();
    return categoryEnum.valueToKey(category);
}
